//
//  ZWNavigationController.swift
//  HZX
//
//  Created by zw on 2017/7/27.
//  Copyright © 2017年 zw. All rights reserved.
//

import UIKit

class ZWNavigationController: UINavigationController {
    
    override func viewDidLoad() {
        super.viewDidLoad()
        navigationBar.tintColor = deepBlackColor
        navigationBar.titleTextAttributes = [NSAttributedString.Key.foregroundColor: UIColor.withHex(hexString: "40320d"),NSAttributedString.Key.font : UIFont.boldSystemFont(ofSize: 17) ]
    }
    
    override func pushViewController(_ viewController: UIViewController, animated: Bool) {
        if viewControllers.count > 0 {
            viewController.hidesBottomBarWhenPushed = true
            let button = UIButton.init(type: .system)
            button.setImage(UIImage(named: "back_1"), for: .normal)
            button.setImage(UIImage(named: "back_2"), for: .highlighted)
            button.contentHorizontalAlignment = .left
            button.frame = CGRect.init(x: 0, y: 0, width: 50, height: 44)
            button.imageEdgeInsets = UIEdgeInsets.init(top: 0, left: -1, bottom: 0, right: 0)
            button.addTarget(self, action: #selector(navigationBack), for: .touchUpInside)
            viewController.navigationItem.leftBarButtonItem = UIBarButtonItem.init(customView: button)
        }
        super.pushViewController(viewController, animated: animated)
    }
    @objc func navigationBack() {
        popViewController(animated: true)
    }
    
}

